<?php

namespace App\Common\Traits;

use App\Models\Attachment;
use Illuminate\Database\Eloquent\Relations\MorphToMany;

trait HasAttachments
{
    /**
     * @return MorphToMany
     */
    public function attachments(): MorphToMany
    {
        return $this->morphToMany(
            Attachment::class,
            'subject',
            'model_has_attachments'
        )->withPivot('type');
    }
}
